package com.pureut.storage.controller;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.storage.dto.IncomingMaterialSubcontractPrintingDto;
import com.pureut.storage.service.IncomingMaterialSubcontractPrintingService;
import com.pureut.storage.vo.IncomingMaterialSubcontractPrintingVo;
import com.pureut.storage.vo.OneKeyWarehousingVo;
import com.pureut.system.api.vo.ReturnStatusVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 委外打印表 控制层
 * Author:C
 * Date:2023/01/16 16:06
 * @DESC
 */
@RestController
@RequestMapping("/incoming-material-subcontract-printing")
public class IncomingMaterialSubcontractPrintingController extends BaseController {

    @Resource
    IncomingMaterialSubcontractPrintingService incomingMaterialSubcontractPrintingService;

    /**
     * 委外打印列表
     */
    @RequiresPermissions("warehouse:incomingPrint:print:list")
    @GetMapping("/list")
    public TableDataInfo getList(IncomingMaterialSubcontractPrintingVo incomingMaterialPrintingVo) {
        startPage();
        //查询采购打印列表
        List<IncomingMaterialSubcontractPrintingDto> list = incomingMaterialSubcontractPrintingService.getSubcontractPrintList(incomingMaterialPrintingVo);
        return getDataTable(list);
    }

    /**
     * 委外打印详情
     */
    @RequiresPermissions("warehouse:incomingPrint:cgPrint:query")
    @GetMapping("/getSubcontractPrintView/{id}")
    public AjaxResult getSubcontractPrintView(@PathVariable("id") long id) {
        return AjaxResult.success(incomingMaterialSubcontractPrintingService.getSubcontractPrintView(id));
    }

    /**
     * 入库
     */
    @RequiresPermissions("warehouse:incomingPrint:cgPrint:warehousing")
    @PostMapping("/oneKeyWarehousing")
    public AjaxResult oneKeyWarehousing(@RequestBody OneKeyWarehousingVo oneKeyWarehousingVo) {
        return toAjax(incomingMaterialSubcontractPrintingService.oneKeyWarehousing(oneKeyWarehousingVo));
    }

    /**
     * 根据唯一标识修改状态(feign调用)
     */
    @PostMapping("/getDataByOnlyMarkSub")
    public AjaxResult getDataByOnlyMarkSub(@RequestBody ReturnStatusVo returnStatusVo) {
        return AjaxResult.success(incomingMaterialSubcontractPrintingService.getDataByOnlyMarkSub(returnStatusVo));
    }
}
